import 'package:flutter/material.dart';
import 'package:flutter_smart_heating/ui/src/html.dart';
import 'package:flutter_smart_heating/ui/ui.dart';
import 'package:get/get.dart';

import 'logic.dart';
import 'state.dart';

class BroadcastDetailPage extends StatelessWidget {
  final BroadcastDetailLogic logic = Get.put(BroadcastDetailLogic());
  final BroadcastDetailState state = Get.find<BroadcastDetailLogic>().state;

  BroadcastDetailPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('正文'),
      ),
      body: UiState(
        controller: state.stateController,
        onLoad: logic.fetchData,
        child: GetBuilder<BroadcastDetailLogic>(
          builder: (context) {
            return ListView(
              padding: const EdgeInsets.all(UiTheme.spacingX),
              children: [
                Text(
                  state.row['title'],
                  style: const TextStyle(
                    fontSize: 20,
                    fontWeight: FontWeight.bold,
                  ),
                ),
                const SizedBox(height: 5),
                Row(
                  children: [
                    const Icon(
                      UiIcons.time_circle,
                      size: 14,
                      color: Colors.grey,
                    ),
                    const SizedBox(width: 4),
                    Text(
                      "${state.row['create_date']}",
                      style: const TextStyle(
                        color: Colors.grey,
                      ),
                    ),
                  ],
                ),
                const Divider(height: UiTheme.spacingXX),
                UiHtml(
                  data: state.row['content'],
                  dense: true,
                ),
              ],
            );
          },
        ),
      ),
    );
  }
}
